package com.example.demo;

import com.example.demo.model.ListConfig;
import com.example.demo.model.Student;
import com.example.demo.model.Student2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author : niu niu
 * @version : 1.0.0
 * @date : 2023/4/13 11:33
 */
@Controller
public class UserController {

    @Value("${server.port}")
    private String port;
    @Value("${spring.datasource.url}")
    private String url;
    @Value("${spring.datasource.username}")
    private String username;
    @Value("${spring.datasource.password}")
    private String password;

    @Autowired
    private Student student ;
    @Autowired
    private Student2 student2 ;
    @Autowired
    private ListConfig listConfig;
    @ResponseBody
    @RequestMapping("/hello")
    public String sayHello(){
        return "hello,springBoot. port:"+port
                +" /nJDBC-url:"+url
                +" /nJDBC-username:"+username
                +" /nJDBC-password:"+password;
    }
    @ResponseBody
    @RequestMapping("/")
    public String studentShow(){
        return student.toString() + student2.toString();
    }
    @ResponseBody
    @RequestMapping("/list")
    public String showList(){
        System.out.println(listConfig.getName().toString());
        return listConfig.getName().toString();
    }

}
